package com.ccys.cms.controller.healthScreening;

import com.ccys.cms.service.healthScreening.TblS3RootFolderWebService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.util.Kit;
import com.ccys.common.vo.ResponseResult;
import com.ccys.db.dto.healthScreening.TblS3RootFolderDTO;
import com.ccys.db.entity.TblS3RootFolder;
import com.ccys.db.vo.healthScreening.TblS3RootFolderWebVO;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "健康检查-Root folder")
@RequestMapping("healthScreening")
@CrossOrigin(methods = {RequestMethod.GET, RequestMethod.POST, RequestMethod.DELETE, RequestMethod.PUT}) // 开启跨域访问允许
@SuppressWarnings("unchecked")
public class S3RootFolderWebController {

    @Autowired
    private TblS3RootFolderWebService tblS3RootFolderWebService;

    @GetMapping("s3RootFolder")
    @ApiOperation("获取列表")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "labName", value = "labName", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),

        @ApiImplicitParam(name = "id", value = "对象id", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "startTime", value = "开始时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "endTime", value = "结束时间(格式 yyyy-mm-dd)", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "orderByStr", value = "排序字段（后端返回的字段  asc升序，desc 降序,加上end后缀。示例（createdOn降序排 则传值 createdOn descend））",paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = TblS3RootFolderWebVO.class)
    })
    public ResponseResult listObjectsCms(HttpServletRequest request, HttpServletResponse response, @ApiIgnore TblS3RootFolderDTO dto) {
        return this.tblS3RootFolderWebService.listObjectsCms(request, response, dto);
    }


    @PostMapping("s3RootFolder")
    @ApiOperation("添加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "labName", value = "labName", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "对应file structure,1:YYYYMMDD_A_1234_G1234567X_JOHN LOH_21-8615222.pdf;2:1. S1234567D-Peter Tan.pdf", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult save(@ApiIgnore TblS3RootFolder entity) {
        entity.setId(null);
        return this.tblS3RootFolderWebService.change(entity);
    }


    @PutMapping("s3RootFolder")
    @ApiOperation("编辑")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "labName", value = "labName", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "name", value = "name", required = false, dataType = "string", paramType = "query"),
        @ApiImplicitParam(name = "type", value = "对应file structure,1:YYYYMMDD_A_1234_G1234567X_JOHN LOH_21-8615222.pdf;2:1. S1234567D-Peter Tan.pdf", required = false, dataType = "string", paramType = "query"),
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult edit(@ApiIgnore TblS3RootFolder entity) {
        Kit.allParamValid(entity, "id");
        return this.tblS3RootFolderWebService.change(entity);
    }


    @DeleteMapping("s3RootFolder")
    @ApiOperation("删除")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "id", value = "ID号", required = true, dataType = "string", paramType = "query")
    })
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC)
    })
    public ResponseResult delete(TblS3RootFolder dto) {
        Kit.allParamValid(dto, "id");
        return this.tblS3RootFolderWebService.delete(dto);
    }

}